package org.jgs1904.quickstart.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author: 默苍璃
 * @date: 2025-06-0515:54
 */
@Controller
public class LoginController {


    // 该方法不执行
    @RequestMapping("/login")
    public String login() {
        System.out.println("登录方法");
        return "main.html";
    }


    /**
     * 成功后跳转页面
     *
     * @return
     */
    @PreAuthorize(("hasRole('ROLE_abc')"))
    @Secured("ROLE_abc")
    @RequestMapping("/toMain")
    public String toMain() {
        return "redirect:/main.html";
    }


    /**
     * 失败后跳转页面
     *
     * @return
     */
    @RequestMapping("/toError")
    public String toError() {
        return "redirect:/error.html";
    }

}
